﻿using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.Linq;
using System.Text;

namespace Cocon90.Lib.Dal.Utility
{
    /// <summary>
    /// SQLite数据操作实例
    /// </summary>
    public class SQLiteDataHelper : DataHelper
    {
        public override System.Data.Common.DbCommand createCommond(string tsqlParamed, System.Data.CommandType commandType, params System.Data.Common.DbParameter[] paramKeyAndValue)
        {
            SQLiteConnection conn = new SQLiteConnection(base.GetConnectionString);
            conn.Open();
            SQLiteCommand cmd = new SQLiteCommand(tsqlParamed, conn);
            cmd.CommandType = commandType;
            foreach (var param in paramKeyAndValue)
            {
                cmd.Parameters.Add(param);
            }
            return cmd;
        }
        public override System.Data.Common.DbDataAdapter createDataAdapter(System.Data.Common.DbCommand selectCmd)
        {
            SQLiteDataAdapter dap = new SQLiteDataAdapter((SQLiteCommand)selectCmd);
            return dap;
        }
        public override System.Data.Common.DbParameter createParameter(string key, object value)
        {
            SQLiteParameter param = new SQLiteParameter(key, value);
            return param;
        }
    }
}
